//
//  XCBaseViewController.m
//  XCBabyBook
//
//  Created by hankeyboard on 2018/12/23.
//  Copyright © 2018 hankeyboard. All rights reserved.
//

#import "XCBaseViewController.h"

typedef void(^LeftButtonLickBlock)(UIButton *button);
@interface XCBaseViewController ()

@property (nonatomic, copy) LeftButtonLickBlock leftClickCb;

@end

@implementation XCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
}

///默认的nav返回箭头的按钮
- (void)showCustomLeftImgBarButton:(void (^)(UIButton *button))clickHandler {
    if (clickHandler) {
        self.leftClickCb = clickHandler;
    }
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(0, 0, 40, 40);
    [backButton setBackgroundImage:[UIImage imageNamed:@"discover_nav_back_circle_nor"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(navLeftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = backItem;
}

- (void)navLeftBtnClick:(UIButton *)button {
    self.leftClickCb(button);
}

-(float)mStatusbarHeight {
    //状态栏高度
    return [[UIApplication sharedApplication] statusBarFrame].size.height;
}

-(float)mNavigationbarHeight {
    //导航栏高度+状态栏高度
    return self.navigationController.navigationBar.frame.size.height + [[UIApplication sharedApplication] statusBarFrame].size.height;
}

-(float)mTabbarHeight {
    //Tabbar高度
    return self.tabBarController.tabBar.bounds.size.height;
}

@end
